namespace Core.Base
{
    using System;
    using System.Globalization;
    using Contracts.Interfaces;
    using Resources;

    /// <summary>
    /// Base cost class
    /// </summary>
    
    public abstract class CostBase : PropertyChangedBase, ICost
    {
        private decimal _value;
        /// <summary>
        /// Initializes a new instance
        /// </summary>
        protected CostBase() { }
        /// <summary>
        /// Initializes a new instance
        /// </summary>
        protected CostBase(decimal value)
            : this()
        {
            if(value < 0)throw new ArgumentOutOfRangeException("value");
            _value = value;
        }

        /// <summary>
        /// Obtains or defines the cost value
        /// </summary>
        public virtual decimal Value
        {
            get { return _value; }
            set
            {
                if(value < 0)throw new ArgumentOutOfRangeException("value");
                _value = value;
                NotifyPropertyChange(()=>Value);
            }
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override string ToString()
        {
            return string.Format(CultureInfo.CurrentCulture, "{0:N2} {1}", Value, Traduction.label_NIC);
        }
    }
}